package com.ap.generator.common;

import static com.ap.datagen.core.GeneratorHelper.buildA;
import static com.ap.datagen.core.GeneratorHelper.fixedValueGenerator;
import static com.ap.datagen.core.GeneratorHelper.randomGeneratorFromArray;
import static com.ap.datagen.core.GeneratorHelper.randomGeneratorFromEnum;
import static com.ap.datagen.core.Nullable.nullable;
import static com.ap.datagen.date.JodaLocalDateTimeGeneratorBuilder.jodaLocalDateTimeGeneratorBuilder;
import static com.ap.datagen.lang.StringRandomGeneratorBuilder.stringRandomGeneratorBuilder;
import static com.ap.generator.common.ResponseStatusTypeGeneratorBuilder.getResponseStatusTypeGenerator;

import org.joda.time.LocalDateTime;

import com.ap.core.common.types.FieldLengthConstants;
import com.ap.core.common.types.RefundMethodType;
import com.ap.core.common.types.RefundReasonType;
import com.ap.core.cxf.jaxb.common.CurrencyCodeType;
import com.ap.core.cxf.jaxb.common.DeliveryType;
import com.ap.core.cxf.jaxb.common.ResponseCode;
import com.ap.core.cxf.jaxb.common.ResponseStatusType;
import com.ap.core.cxf.jaxb.distributor.MerchantStatus;
import com.ap.core.cxf.jaxb.distributor.MerchantTypeEnum;
import com.ap.core.cxf.jaxb.managemerchant.RegisterMerchantMessageType;
import com.ap.core.cxf.jaxb.managepayment.RetrieveRTPMessageType;
import com.ap.core.cxf.jaxb.managepayment.RetrieveRTPMsgHdrType;
import com.ap.core.cxf.jaxb.managertp.EnquireRTPStatusMsgHdrType;
import com.ap.core.cxf.jaxb.managertp.EnquireRTPStatusMsgType;
import com.ap.core.cxf.jaxb.managertp.SubmitRTPMessageType;
import com.ap.core.cxf.jaxb.managertp.SubmitRTPMsgHdrType;
import com.ap.core.cxf.jaxb.msghdr.MessageType;
import com.ap.core.cxf.jaxb.msghdr.MsgHdrType;
import com.ap.core.cxf.jaxb.paymentdetails.TransactionStatusCode;
import com.ap.core.cxf.jaxb.paymentdetails.TxnStatusType;
import com.ap.datagen.Generator;
import com.ap.datagen.core.GeneratorHelper;
import com.ap.datagen.core.Nullable;
import com.ap.datagen.lang.IntegerRandomGeneratorBuilder;
import com.ap.datagen.lang.StringRandomGeneratorBuilder;
import com.ap.datagen.math.BigDecimalRandomGeneratorBuilder;
import com.ap.generator.messageheader.EnquireRTPStatusMsgHdrTypeGeneratorBuilder;
import com.ap.generator.messageheader.MsgHdrTypeGeneratorBuilder;
import com.ap.generator.messageheader.RetrieveRTPMsgHdrTypeGeneratorBuilder;
import com.ap.generator.messageheader.SubmitRTPMsgHdrTypeGeneratorBuilder;
import com.ap.generator.registermerchant.RequestMerchantRegistrationMsgHdrTypeGeneratorBuilder;

public class FieldGenerator {
	public static final Nullable<Generator<String>> DISTRIBUTORIDGENERATOR = nullable(stringRandomGeneratorBuilder()
			.numeric().length(FieldLengthConstants.DISTRIBUTORID).build());

	public static final Nullable<Generator<String>> DISTRIBUTORNAMEGENERATOR = nullable(stringRandomGeneratorBuilder()
			.length(FieldLengthConstants.DISTRIBUTORNAME).build());

	public static final Nullable<Generator<String>> MERCHANTCMNNAMEGENERATOR = nullable(stringRandomGeneratorBuilder()
			.length(FieldLengthConstants.MERCHANTCMNNAME).build());

	public static final Nullable<Generator<String>> MERCHANTIDGENERATOR = nullable(stringRandomGeneratorBuilder().numeric()
			.length(FieldLengthConstants.MERCHANTID).build());

	public static final Nullable<Generator<String>> MERCHANTNAMEGENERATOR = nullable(stringRandomGeneratorBuilder()
			.length(FieldLengthConstants.MERCHANTNAME).build());
	
	public static final Nullable<Generator<String>> MERCHANTREDIRECTURLGENERATOR = nullable(stringRandomGeneratorBuilder()
			.length(FieldLengthConstants.MERCHANTREDIRECTURL).build());

	public static final Nullable<Generator<String>> APTRANSACTIONIDGENERATOR = nullable(StringRandomGeneratorBuilder
			.stringRandomGeneratorBuilder()
			.length(FieldLengthConstants.APTRANSACTIONID).alphanumericUpper()
			.build());
	
	public static final Nullable<Generator<String>> APTRANSACTIONRETRIEVEIDGENERATOR = nullable(StringRandomGeneratorBuilder
			.stringRandomGeneratorBuilder()
			.length(FieldLengthConstants.APTRANSACTIONRETRIEVALID).alphanumericUpper()
			.build());
	public static final Nullable<Generator<String>> APINBIDGENERATOR = nullable(stringRandomGeneratorBuilder()
			.alphanumericUpper().length(FieldLengthConstants.APINBID).build());

	public static final Nullable<Generator<String>> INBMOBILENUMBERGENERATOR = nullable(stringRandomGeneratorBuilder()
			.alphanumericUpper().length(FieldLengthConstants.INBMOBILENUMBER)
			.build());

	public static final Nullable<Generator<String>> PASSWORDGENERATOR = nullable(stringRandomGeneratorBuilder()
			.alphanumericUpper().minLength(FieldLengthConstants.PASSWORD_MIN)
			.maxLength(FieldLengthConstants.PASSWORD_MAX).build());

	public static final Nullable<Generator<MsgHdrType>> MSGHDRGENERATOR = nullable(buildA(MsgHdrTypeGeneratorBuilder.msgHdrTypeGenerator().withMsgType(MessageType.SUBMITRTPFORMOB)));
	public static final Nullable<Generator<SubmitRTPMsgHdrType>> MSGHDRGENERATORSUBMITRTP = nullable(buildA(SubmitRTPMsgHdrTypeGeneratorBuilder.msgHdrTypeGenerator().withMsgType(SubmitRTPMessageType.SUBMITRTPFORMOB)));
    public static final Nullable<Generator<EnquireRTPStatusMsgHdrType>> MSGHDRGENERATORENQUIRERTPSTATUS = nullable(buildA(EnquireRTPStatusMsgHdrTypeGeneratorBuilder.msgHdrTypeGenerator().withMsgType(EnquireRTPStatusMsgType.REQUESTRTPSTATUS)));

    public static final Nullable<Generator<com.ap.core.cxf.jaxb.managemerchant.RegisterMerchantMsgHdrType>> ADDMERCHANTMSGHDRGENERATOR = nullable(buildA(RequestMerchantRegistrationMsgHdrTypeGeneratorBuilder.msgHdrTypeGenerator().withMsgType(RegisterMerchantMessageType.ADDMERCHANT)));

    public static final Nullable<Generator<RetrieveRTPMsgHdrType>> MSGHDRGENERATORRETREIVERTP = nullable(buildA(RetrieveRTPMsgHdrTypeGeneratorBuilder.msgHdrTypeGenerator().withMsgType(RetrieveRTPMessageType.RETRIEVERTP)));

	public static final Nullable<Generator<String>> ADHOCGENERATOR = nullable(StringRandomGeneratorBuilder
			.stringRandomGeneratorBuilder().length(FieldLengthConstants.ADHOC)
			.build());

	/*public static final Nullable<Generator<DefaultFlagEnum>> DEFAULTFLAGGENERATOR = nullable(fixedValueGenerator(DefaultFlagEnum.YES));

	public static final Nullable<Generator<UpdateTypeEnum>> UPDATETYPEGENERATOR = nullable(fixedValueGenerator(UpdateTypeEnum.ADD));

	public static final Nullable<Generator<ActivationStatusEnum>> ACTIVATIONSTATUSGENERATOR = nullable(fixedValueGenerator(ActivationStatusEnum.ACTIVE));

	public static final Nullable<Generator<String>> CONSUMERPORTALURLGENERATOR = nullable(stringRandomGeneratorBuilder()
			.alphanumericUpper().length(FieldLengthConstants.CONSUMERPORTALURL)
			.build());

	public static final Nullable<Generator<UpdateStatusEnum>> UPDATESTATUSGENERATOR = nullable(fixedValueGenerator(UpdateStatusEnum.SUCCESSFUL));*/

	public static final Nullable<Generator<String>> EMAILADDRESSGENERATOR = nullable(GeneratorHelper
			.fixedValueGenerator("noreply@ap.com"));

	public static final Nullable<Generator<DeliveryType>> DELIVERYTYPEGENERATOR = nullable(randomGeneratorFromEnum(DeliveryType.DIGDEL));

	public static final Nullable<Generator<String>> FICONSUMERIDGENERATOR = nullable(stringRandomGeneratorBuilder()
			.length(FieldLengthConstants.FICONSUMERID).build());

	public static final Nullable<Generator<String>> FISHORTNAMEGENERATOR = nullable(stringRandomGeneratorBuilder()
			.alphabeticUppper().length(FieldLengthConstants.FISHORTNAME)
			.build());

	/*public static final Nullable<Generator<List<BankAcctType>>> BANKACCTGENERATOR = nullable(GeneratorHelper
			.generateList(BankAcctTypeGeneratorBuilder
					.getBankAcctTypeGenerator().withAcctBalance().build(),
					GeneratorHelper.fixedValueGenerator(1)));*/

	public static final Nullable<Generator<String>> FIIDGENERATOR = nullable(stringRandomGeneratorBuilder()
			.length(FieldLengthConstants.FIID).build());

	public static final Nullable<Generator<Integer>> BRNGENERATOR = nullable(IntegerRandomGeneratorBuilder
			.integerRandomGeneratorBuilder()
			.least(FieldLengthConstants.BRN_MIN_RANGE)
			.bound(FieldLengthConstants.BRN_MAX_RANGE).build());

	public static final Nullable<Generator<String>> FASTERPAYMENTSREFGENERATOR = nullable(stringRandomGeneratorBuilder()
			.length(FieldLengthConstants.FASTERPAYMENTSREF).build());

	private static final String[] COUNTRY_CODES = new String[] { "GBR" };

	private static final String[] POST_CODES = new String[] { "RK12", "RK13",
	"RK14" };

	public static final Nullable<Generator<String>> COUNTRYCODEGENERATOR = nullable(randomGeneratorFromArray(COUNTRY_CODES));
	
	private static final String[] MERCHANT_CATEGORY_CODES = new String[] { "1001","1002","1003","1004" };
	public static final Nullable<Generator<String>> MERCHANTCATEGORYCODESGENERATOR = nullable(randomGeneratorFromArray(MERCHANT_CATEGORY_CODES));

	public static final Nullable<Generator<String>> INMERCHANTURLGENERATOR = nullable(GeneratorHelper
			.fixedValueGenerator("http://www.mechant.com"));

	public static final Nullable<Generator<String>> COMAPNYREGNUMGENERATOR = nullable(stringRandomGeneratorBuilder()
			.length(FieldLengthConstants.COMAPNYREGNUM).build());

	public static final Nullable<Generator<MerchantStatus>> MERCHANTSTATUSGENERATOR = nullable(fixedValueGenerator(MerchantStatus.ACTIVE));

	public static final Nullable<Generator<MerchantTypeEnum>> MERCHANTTYPEGENERATOR = nullable(fixedValueGenerator(MerchantTypeEnum.ONLINE));

	public static final Nullable<Generator<String>> OFFLOADREASONGENERATOR = nullable(stringRandomGeneratorBuilder()
			.length(FieldLengthConstants.OFFLOADREASON).build());

	public static final Nullable<Generator<String>> SETTLEMENTFILEIDGENERATOR = nullable(stringRandomGeneratorBuilder()
			.length(FieldLengthConstants.SETTLEMENTFILEID).build());

	public static final Nullable<Generator<String>> MERCHANTCONTACTNUMBERGENERATOR = nullable(stringRandomGeneratorBuilder()
			.length(FieldLengthConstants.MERCHANTCONTACTNUMBER).build());

	public static final Nullable<Generator<String>> MERCHANTVATNUMBERGENERATOR = nullable(stringRandomGeneratorBuilder()
			.length(FieldLengthConstants.MERCHANTVATNUMBER).build());

	public static final Nullable<Generator<String>> RTPIDGENERATOR = nullable(StringRandomGeneratorBuilder
			.stringRandomGeneratorBuilder().length(FieldLengthConstants.RTPID)
			.alphanumericUpper().build());

	public static final Nullable<Generator<String>> RECONIDGENERATOR = nullable(StringRandomGeneratorBuilder
			.stringRandomGeneratorBuilder()
			.length(FieldLengthConstants.RECONID).alphanumericUpper().build());

	public static final Nullable<Generator<ResponseStatusType>> RESPONSESTATUSGENERATOR = nullable(buildA(getResponseStatusTypeGenerator().withResponseCode(ResponseCode.SUCCESSFUL)));

	public static final Nullable<Generator<String>> MOBAPPINTENTGENERATOR = nullable(StringRandomGeneratorBuilder
			.stringRandomGeneratorBuilder()
			.length(FieldLengthConstants.MOBILEAPPINTENT).alphanumericUpper()
			.build());

	public static final Nullable<Generator<String>> POSTCODEGENERATOR = nullable(GeneratorHelper
			.randomGeneratorFromArray(POST_CODES));

	public static final Nullable<Generator<String>> ADDRESSLINE1GENERATOR = nullable(stringRandomGeneratorBuilder()
			.length(FieldLengthConstants.ADDRESSLINE1).build());

	public static final Nullable<Generator<String>> ADDRESSLINE2GENERATOR = nullable(stringRandomGeneratorBuilder()
			.length(FieldLengthConstants.ADDRESSLINE2).build());

	public static final Nullable<Generator<String>> ADDRESSLINE3GENERATOR = nullable(stringRandomGeneratorBuilder()
			.length(FieldLengthConstants.ADDRESSLINE3).build());

	public static final Nullable<Generator<String>> ADDRESSLINE4GENERATOR = nullable(stringRandomGeneratorBuilder()
			.length(FieldLengthConstants.ADDRESSLINE4).build());

	public static final Nullable<Generator<String>> ADDRESSLINE5GENERATOR = nullable(stringRandomGeneratorBuilder()
			.length(FieldLengthConstants.ADDRESSLINE5).build());

	public static final Nullable<Generator<String>> ADDRESSLINE6GENERATOR = nullable(stringRandomGeneratorBuilder()
			.length(FieldLengthConstants.ADDRESSLINE6).build());

	public static final Nullable<Generator<String>> ORGREQMSGIDGENERATOR = nullable(stringRandomGeneratorBuilder()
			.length(FieldLengthConstants.ORGREQMSGID).build());
		
	public static final Nullable<Generator<TxnStatusType>> TXNSTATUSCODEGENERATOR = nullable(fixedValueGenerator(TxnStatusType.AUTHORISED));
	
	public static final Nullable<Generator<CurrencyCodeType>> CURRENCYGENERATOR = nullable(GeneratorHelper
			.randomGeneratorFromEnum(CurrencyCodeType.GBP));
	
	public static final Nullable<Generator<java.math.BigDecimal>> AMOUNTGENERATOR = nullable(BigDecimalRandomGeneratorBuilder
			.bigDecimalRandomGeneratorBuilder().build());
	
	public static final Nullable<Generator<LocalDateTime>> TIMESTAMPGENERATOR = nullable(jodaLocalDateTimeGeneratorBuilder().build()); 
	
	public static final Nullable<Generator<String>> FIACCTGENERATOR = nullable(stringRandomGeneratorBuilder()
			.length(FieldLengthConstants.ACCTNUM).build());
	
	public static final Nullable<Generator<String>> ACCTSORTCODEGENERATOR = Nullable
			.nullable(StringRandomGeneratorBuilder
					.stringRandomGeneratorBuilder().numeric()
					.length(FieldLengthConstants.ACCTSORTCODE).build());
	
	public static final Nullable<Generator<TransactionStatusCode>> FAILUREDESCGENERATOR = nullable(GeneratorHelper
			.randomGeneratorFromEnum(TransactionStatusCode.A_01));
	
	public static final Nullable<Generator<TransactionStatusCode>> SUCCESSTXNSTATUSCODEGENERATOR = nullable(GeneratorHelper
			.fixedValueGenerator(TransactionStatusCode.A_00));
	
	public static final Nullable<Generator<String>> MERCHANTREFUNDREFGENERATOR = nullable(stringRandomGeneratorBuilder()
			.length(FieldLengthConstants.MERCHANTREFUNDREF).build());
	
	public static final Nullable<Generator<String>> REFUNDREASONTYPEGENERATOR = nullable(fixedValueGenerator(RefundReasonType.GOODSRETURNED.name()));
	
	public static final Nullable<Generator<String>> REFUNDMETHODTYPEGENERATOR = nullable(fixedValueGenerator(RefundMethodType.FPS.name()));

}
